HAL PKA migration: List of applicable concepts

This section provides information about the HAL PKA applicable architecture concepts.

Concepts for PKA

Concept

Description

Separation of initialization and configuration functions

Provide a distinct configuration for each operating mode, using only the parameters strictly required for that mode.

Renaming of the handle structure

The handle structure has been renamed to hal_pka_handle_t.

Remove MspInit and MspDeInit callbacks

HAL_PKA_MspInit and HAL_PKA_MspDeInit are no longer available and have been replaced by a user sequence to initializes and configures the PKA.

Introduction of HAL user data set/get APIs

Two functions to set and get user data are available: HAL_PKA_SetUserData() and HAL_PKA_GetUserData().

Individual callback registration APIs replace global register and unregister functions

The callback registration is handled by specific functions for each PKA event. These functions are used to register callback functions for different PKA events.

HAL implementation with LL inline functions

HAL PKA APIs now rely on LL APIs rather than performing direct register access.

Define statements and enumerations redirected to LL equivalents

HAL PKA define statements and enumerations are based on LL define statements.

Removal of hardware-related macros in HAL2

All hardware macros have been removed from the HAL PKA driver, and equivalent services are ensured through the LL APIs.

Revised and optimized HAL state machine

The PKA state machine is reworked to ensure transitions of the peripheral functional states.

Revised and optimized HAL API status returns

The HAL PKA functions were updated to return:

  • HAL_INVALID_PARAM: in case of a NULL p_config structure pointer.

  • HAL_ERROR: in case of an error.

  • HAL_TIMEOUT: in case of a user timeout.

  • HAL_BUSY: in case of an ongoing process.

  • HAL_OK: in case of a successfully completed operation.

Revised and optimized HAL error management

Involves redesigning the error handling mechanisms within the HAL to improve the detection, reporting, and handling of errors.

Replaced TypeDef suffix with _t in type names

All TypeDef parts of the HAL PKA driver have been removed and replaced by _t.

Replaced nonmodifiable pointers with const keywords

Const keywords have been added to non-modifiable pointers to ensure that either the pointer itself or the data it points to cannot be modified. This enhances code safety and readability, prevents unintended modifications, and renders code more robust and maintainable.

Assertion implementation and usage in HAL1

The parameters and state are checked using ASSERT_DBG_STATE and ASSERT_DBG_PARAM macros.

Remove stm32tnxx_ll_ppp.c files

The source file stm32_ll_pka.c is removed in HAL2 .

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Finite parameters (including PKA instances) have been converted into enumerated types (enums) at HAL level. This improves code readability, maintainability, and type safety.

Optimize HAL PPP IRQ Handlers by Reordering Processes and Error Management Statements to Prioritize Critical Interrupts

In HAL2, the implementation of HAL_PKA_IRQHandler API has been improved to prioritize the handling of critical interrupts.

Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions).

All HAL PKA functions start with HAL_PKA. All HAL PKA enumerations and structures start with hal_pka.

Other HAL PKA changes

Concept

Consideration

Provide APIs that return the PKA calculation results and effective data size in byte.

The following functions do not provide the correct length due to different IP HW version:

HAL_PKA_ModExp_GetResult(), HAL_PKA_ECDSASign_GetResult(), HAL_PKA_ECCMul_GetResult().

Split operation process from operation configuration.

For each compute operation, a dedicated configuration API is provided, and a single compute API is used for all operations.